import datetime
import os.path
import sys
from selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager

class Driver:
    def __init__(self):
        edge_driver_path = r"D:\edgedriver_win64\msedgedriver.exe"
        options=webdriver.EdgeOptions()
        self.driver = webdriver.Edge(service=EdgeService(executable_path=edge_driver_path),options=options)
        self.driver.maximize_window()
        self.driver.implicitly_wait(5)
    # 截图功能
    def getScreeShot(self):
        dirname = datetime.datetime.now().strftime("%Y-%m-%d")
        # 不存该目录在则创建
        if not os.path.exists("../images/"+dirname):
            os.mkdir("../images/"+dirname)
        filename = sys._getframe().f_back.f_code.co_name+"-"+datetime.datetime.now().strftime("%Y-%m-%d-%H%M%S")+".png"
        self.driver.save_screenshot("../images/"+dirname+"/"+filename)

ForumDriver = Driver()